﻿<UserControl x:Class="HSS.Interlink.UploadFileView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:interlink="clr-namespace:HSS.Interlink"
	>
	<UserControl.Resources>
		<interlink:ByteConverter x:Key="ByteConverter"/>
		<interlink:PercentageConverter x:Key="PercentageConverter"/>
		<Style x:Key="ImageButtonStyle" TargetType="Button">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="Button">
						<Grid>
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver"/>
									<VisualState x:Name="Pressed"/>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<DoubleAnimation Duration="0" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="Opacity" To=".55"/>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
								<VisualStateGroup x:Name="FocusStates">
									<VisualState x:Name="Focused"/>
									<VisualState x:Name="Unfocused" />
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="Right" VerticalAlignment="Center">
								<Image Source="{TemplateBinding Content}" />
							</ContentPresenter>
							<Rectangle x:Name="DisabledVisualElement" RadiusX="2" RadiusY="2" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<Grid x:Name="LayoutRoot" Margin="2" Background="Transparent" >
		<VisualStateManager.VisualStateGroups>
			<VisualStateGroup x:Name="DownloadStates">
				<VisualState x:Name="Ready">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Pending">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnRemove" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileName" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileSize" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Uploading">
					<Storyboard>
						<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="btnCancel" Storyboard.TargetProperty="(UIElement.Visibility)">
							<DiscreteObjectKeyFrame KeyTime="00:00:00">
								<DiscreteObjectKeyFrame.Value>
									<Visibility>Visible</Visibility>
								</DiscreteObjectKeyFrame.Value>
							</DiscreteObjectKeyFrame>
						</ObjectAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileName" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileSize" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Error">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Brown"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="CancelPending">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileName" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileSize" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Canceling">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileName" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileSize" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Canceled">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileName" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtFileSize" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="Gray"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Finished">
					<Storyboard>
						<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="txtState" Storyboard.TargetProperty="(TextBlock.Foreground).(SolidColorBrush.Color)">
							<EasingColorKeyFrame KeyTime="00:00:00" Value="#FF4B6F3C"/>
						</ColorAnimationUsingKeyFrames>
					</Storyboard>
				</VisualState>
				<VisualState x:Name="Removed"/>
			</VisualStateGroup>
		</VisualStateManager.VisualStateGroups>
		<Grid.ColumnDefinitions>
			<ColumnDefinition />
			<ColumnDefinition />
			<ColumnDefinition />
			<ColumnDefinition />
			<ColumnDefinition />
			<ColumnDefinition />
		</Grid.ColumnDefinitions>
		<Button Grid.Column="0" x:Name="btnFileInfo" Command="{Binding ShowDetailCommand}" Style="{StaticResource ImageButtonStyle}" Cursor="Hand" Content="assets/information.png" HorizontalAlignment="Left" ToolTipService.Placement="Top" ToolTipService.ToolTip="View file info..." Height="16" Margin="0,0,5,0" IsTabStop="False" />
		<TextBlock Grid.Column="1" x:Name="txtFileName" Text="{Binding FileName}" Margin="0,0,5,0" Width="215" HorizontalAlignment="Stretch" ToolTipService.ToolTip="{Binding ToolTipText}" />
		<TextBlock Grid.Column="2" x:Name="txtState" Text="{Binding State}" Width="60" TextAlignment="Left" />
		<TextBlock Grid.Column="3" x:Name="txtFileSize" Text="{Binding FileLength, Converter={StaticResource ByteConverter}}" Width="65" TextAlignment="Left" Margin="0,0,5,0" />
		<Grid Grid.Column="4" >
			<ProgressBar Value="{Binding Percentage}" Width="60" HorizontalAlignment="Center" IsTabStop="False" />
			<TextBlock Text="{Binding Percentage, Converter={StaticResource PercentageConverter}}" Width="60" TextAlignment="Center"/>
		</Grid>
		<StackPanel Grid.Column="5" x:Name="Actions" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
			<Button x:Name="btnRemove" Style="{StaticResource ImageButtonStyle}" ToolTipService.Placement="Top" ToolTipService.ToolTip="Remove file..." Content="assets/remove.png" Height="15" Margin="18,0,0,0" Visibility="Collapsed" IsTabStop="False" Cursor="Hand" Command="{Binding RemoveCommand}" />
			<Button x:Name="btnCancel" Style="{StaticResource ImageButtonStyle}" ToolTipService.Placement="Top" ToolTipService.ToolTip="Cancel upload..." Content="assets/cancel.png" Height="15" Margin="18,0,0,0" Visibility="Collapsed" IsTabStop="False" Cursor="Hand" Command="{Binding CancelCommand}" />
		</StackPanel>
	</Grid>
</UserControl>
